#include <base_network.hpp>
Public Types | |
typedef _bus | BusType |
typedef _branch | BranchType |
typedef boost::shared_ptr< _bus > | BusPtr |
typedef boost::shared_ptr < _branch > | BranchPtr |
Public Member Functions | |
BaseNetwork (const parallel::Communicator &comm) | |
virtual | ~BaseNetwork (void) |
void | addBus (int idx) |
void | addBranch (int idx1, int idx2) |
int | numBuses (void) |
int | totalBuses (void) |
int | numBranches (void) |
int | totalBranches (void) |
void | setReferenceBus (int idx) |
int | getReferenceBus (void) const |
bool | setOriginalBusIndex (int idx, int o_idx) |
bool | setGlobalBusIndex (int idx, int g_idx) |
bool | setGlobalBranchIndex (int idx, int g_idx) |
bool | setOriginalBusIndex1 (int idx, int b_idx) |
bool | setOriginalBusIndex2 (int idx, int b_idx) |
bool | setGlobalBusIndex1 (int idx, int b_idx) |
bool | setGlobalBusIndex2 (int idx, int b_idx) |
bool | setLocalBusIndex1 (int idx, int b_idx) |
bool | setLocalBusIndex2 (int idx, int b_idx) |
bool | setActiveBus (int idx, bool flag) |
bool | setActiveBranch (int idx, bool flag) |
bool | clearBranchNeighbors (int idx) |
bool | addBranchNeighbor (int idx, int br_idx) |
bool | getActiveBus (int idx) |
int | getOriginalBusIndex (int idx) |
int | getGlobalBusIndex (int idx) |
BusPtr | getBus (int idx) |
bool | getActiveBranch (int idx) |
int | getGlobalBranchIndex (int idx) |
BranchPtr | getBranch (int idx) |
void | getOriginalBranchEndpoints (int idx, int *idx1, int *idx2) |
boost::shared_ptr < component::DataCollection > | getBusData (int idx) |
boost::shared_ptr < component::DataCollection > | getBranchData (int idx) |
std::vector< int > | getConnectedBranches (int idx) const |
std::vector< int > | getConnectedBuses (int idx) const |
void | getBranchEndpoints (int idx, int *bus1, int *bus2) const |
void | assemble (void) |
Assemble local part of network. | |
void | partition (void) |
void | clean (void) |
template<class _new_bus , class _new_branch > | |
void | clone (boost::shared_ptr< gridpack::network::BaseNetwork< _new_bus, _new_branch > > &new_network) |
void | resetGlobalIndices (bool flag) |
void | clear (void) |
void | allocXCBus (int size) |
void | freeXCBus (void) |
void | allocXCBusPointers (int size) |
void | setXCBusBuffer (int idx, void *ptr) |
void * | getXCBusBuffer (int idx) |
void | allocXCBranch (int size) |
void | freeXCBranch (void) |
void * | getXCBranchBuffer (int idx) |
void | allocXCBranchPointers (int size) |
void | setXCBranchBuffer (int idx, void *ptr) |
void | initBusUpdate (void) |
void | updateBuses (void) |
void | initBranchUpdate (void) |
void | updateBranches (void) |
void | writeGraph (const std::string &outname) |
void | setMap (void) |
std::vector< int > | getLocalBusIndices (int idx) |
std::vector< int > | getLocalBranchIndices (int idx1, int idx2) |
boost::shared_ptr < gridpack::component::DataCollection > | getNetworkData () |
void | broadcastNetworkData (int idx) |
Protected Member Functions | |
BaseNetwork (const BaseNetwork &old) |
class BaseNetwork: This is the base class for creating distributed networks. It is basically a container that supports the network topology, allows user-defined buses and branches to be added to the network and has containers that can be used to store parameters for input or output. BaseNetwork also implements ghost bus and ghost branch update for the network. The BaseNetwork class also contains the partitioner, although this is implemented using several additional classes to encapsulate the partitioner from the remainder of the network class.
typedef boost::shared_ptr<_branch> gridpack::network::BaseNetwork< _bus, _branch >::BranchPtr |
typedef _branch gridpack::network::BaseNetwork< _bus, _branch >::BranchType |
typedef boost::shared_ptr<_bus> gridpack::network::BaseNetwork< _bus, _branch >::BusPtr |
typedef _bus gridpack::network::BaseNetwork< _bus, _branch >::BusType |
Type declarations that can be used external to the BaseNetwork class
gridpack::network::BaseNetwork< _bus, _branch >::BaseNetwork | ( | const parallel::Communicator & | comm | ) | [explicit] |
Default constructor.
virtual gridpack::network::BaseNetwork< _bus, _branch >::~BaseNetwork | ( | void | ) | [virtual] |
Default destructor.
gridpack::network::BaseNetwork< _bus, _branch >::BaseNetwork | ( | const BaseNetwork< _bus, _branch > & | old | ) | [protected] |
Protected copy constructor to avoid unwanted copies.
void gridpack::network::BaseNetwork< _bus, _branch >::addBranch | ( | int | idx1, | |
int | idx2 | |||
) |
Add a branch locally to the network. A branch is defined by buses at either end
idx1 | original bus index of bus 1 | |
idx2 | original bus index of bus 2 |
bool gridpack::network::BaseNetwork< _bus, _branch >::addBranchNeighbor | ( | int | idx, | |
int | br_idx | |||
) |
Add local index for a branch attached to bus at idx
idx | local index of bus | |
br_idx | local index of branch attached to bus |
void gridpack::network::BaseNetwork< _bus, _branch >::addBus | ( | int | idx | ) |
Add a bus locally to the network
idx | original index of bus |
void gridpack::network::BaseNetwork< _bus, _branch >::allocXCBranch | ( | int | size | ) |
Allocate buffers for exchanging data for ghost branches
size | size (in bytes) of buffer |
void gridpack::network::BaseNetwork< _bus, _branch >::allocXCBranchPointers | ( | int | size | ) |
Allocate array of pointers to buffers for exchanging data for ghost branchs
size | size of buffers that will be assigned to pointers |
void gridpack::network::BaseNetwork< _bus, _branch >::allocXCBus | ( | int | size | ) |
Allocate array of pointers to buffers for exchanging data for ghost buses
size | size (in bytes) of buffer |
void gridpack::network::BaseNetwork< _bus, _branch >::allocXCBusPointers | ( | int | size | ) |
Allocate buffers for exchanging data for ghost buses
size | size of buffers that will be assigned to pointers |
void gridpack::network::BaseNetwork< _bus, _branch >::assemble | ( | void | ) |
Assemble local part of network.
void gridpack::network::BaseNetwork< _bus, _branch >::broadcastNetworkData | ( | int | idx | ) |
Broadcast network data object from one processor to remaining processors on network communicator
rank | of processor that acts as root for broadcast |
References gridpack::parallel::Distributed::communicator().
void gridpack::network::BaseNetwork< _bus, _branch >::clean | ( | void | ) |
Clean all ghost buses and branches from the system. This can be used before repartitioning the network. This operation also removes all exchange buffers, so these need to be reallocated after calling this method
References gridpack::network::BaseNetwork< _bus, _branch >::freeXCBranch(), and gridpack::network::BaseNetwork< _bus, _branch >::freeXCBus().
void gridpack::network::BaseNetwork< _bus, _branch >::clear | ( | void | ) |
Remove all buses and branches from the system.
bool gridpack::network::BaseNetwork< _bus, _branch >::clearBranchNeighbors | ( | int | idx | ) |
Clear the list of neighbors for the bus at idx
idx | local index of bus |
void gridpack::network::BaseNetwork< _bus, _branch >::clone | ( | boost::shared_ptr< gridpack::network::BaseNetwork< _new_bus, _new_branch > > & | new_network | ) |
Copy network to new network. The component classes of the new network do not need to be the same as the component classes of the old network. This function can be used to create different types of networks that can be used to solve different problems. The new network is already partitioned so it is not necessary to call the partitioner.
References gridpack::network::BaseNetwork< _bus, _branch >::getActiveBranch(), gridpack::network::BaseNetwork< _bus, _branch >::getActiveBus(), gridpack::network::BaseNetwork< _bus, _branch >::getBranchData(), gridpack::network::BaseNetwork< _bus, _branch >::getBranchEndpoints(), gridpack::network::BaseNetwork< _bus, _branch >::getBusData(), gridpack::network::BaseNetwork< _bus, _branch >::getConnectedBranches(), gridpack::network::BaseNetwork< _bus, _branch >::getGlobalBranchIndex(), gridpack::network::BaseNetwork< _bus, _branch >::getGlobalBusIndex(), gridpack::network::BaseNetwork< _bus, _branch >::getOriginalBranchEndpoints(), gridpack::network::BaseNetwork< _bus, _branch >::getOriginalBusIndex(), gridpack::network::BaseNetwork< _bus, _branch >::getReferenceBus(), gridpack::network::BaseNetwork< _bus, _branch >::numBranches(), and gridpack::network::BaseNetwork< _bus, _branch >::numBuses().
void gridpack::network::BaseNetwork< _bus, _branch >::freeXCBranch | ( | void | ) |
Free buffers for exchange of bus data
void gridpack::network::BaseNetwork< _bus, _branch >::freeXCBus | ( | void | ) |
Free buffers for exchange of bus data
bool gridpack::network::BaseNetwork< _bus, _branch >::getActiveBranch | ( | int | idx | ) |
Get status of the branch (local or ghosted)
idx | local index of branch |
bool gridpack::network::BaseNetwork< _bus, _branch >::getActiveBus | ( | int | idx | ) |
Get status of the bus (local or ghosted)
idx | local index of bus |
BranchPtr gridpack::network::BaseNetwork< _bus, _branch >::getBranch | ( | int | idx | ) |
Retrieve a pointer to an existing branch
idx | local index of requested branch |
boost::shared_ptr<component::DataCollection> gridpack::network::BaseNetwork< _bus, _branch >::getBranchData | ( | int | idx | ) |
Retrieve a pointer to the DataCollection object associated with branch indexed by idx
idx | local index of requested branch |
void gridpack::network::BaseNetwork< _bus, _branch >::getBranchEndpoints | ( | int | idx, | |
int * | bus1, | |||
int * | bus2 | |||
) | const |
Return indices of buses at either end of branch
idx | local branch index | |
bus1 | local index of bus at one end of branch | |
bus2 | local index of bus at other end of branch |
BusPtr gridpack::network::BaseNetwork< _bus, _branch >::getBus | ( | int | idx | ) |
Retrieve a pointer to an existing bus
idx | local index of requested bus |
boost::shared_ptr<component::DataCollection> gridpack::network::BaseNetwork< _bus, _branch >::getBusData | ( | int | idx | ) |
Retrieve a pointer to the DataCollection object associated with bus indexed by idx
idx | local index of requested bus |
std::vector<int> gridpack::network::BaseNetwork< _bus, _branch >::getConnectedBranches | ( | int | idx | ) | const |
Return list of branches connected to bus
idx | local bus index |
std::vector<int> gridpack::network::BaseNetwork< _bus, _branch >::getConnectedBuses | ( | int | idx | ) | const |
Return list of buses connected to central bus via one branch
idx | local bus index |
int gridpack::network::BaseNetwork< _bus, _branch >::getGlobalBranchIndex | ( | int | idx | ) |
Get global index of the branch
idx | local index of branch |
int gridpack::network::BaseNetwork< _bus, _branch >::getGlobalBusIndex | ( | int | idx | ) |
Get global index of the bus
idx | local index of bus |
std::vector<int> gridpack::network::BaseNetwork< _bus, _branch >::getLocalBranchIndices | ( | int | idx1, | |
int | idx2 | |||
) |
Find the local indices given the original bus pair indices of a branch.
idx1 | original index of bus1 | |
idx2 | original index of bus2 |
std::vector<int> gridpack::network::BaseNetwork< _bus, _branch >::getLocalBusIndices | ( | int | idx | ) |
Find the local indices given the original index of a bus. Ghost buses may show up more than once.
idx | original index of bus |
boost::shared_ptr<gridpack::component::DataCollection> gridpack::network::BaseNetwork< _bus, _branch >::getNetworkData | ( | ) |
Return a boost pointer to the DataCollection object containing parameters that describe the network as a whole
void gridpack::network::BaseNetwork< _bus, _branch >::getOriginalBranchEndpoints | ( | int | idx, | |
int * | idx1, | |||
int * | idx2 | |||
) |
Get original indices of the two buses at each end of a branch
idx | local index of branch | |
idx1 | original index of "from" bus | |
idx1 | original index of "to" bus |
int gridpack::network::BaseNetwork< _bus, _branch >::getOriginalBusIndex | ( | int | idx | ) |
Get original index of the bus
idx | local index of bus |
int gridpack::network::BaseNetwork< _bus, _branch >::getReferenceBus | ( | void | ) | const |
Return index of reference bus.
void* gridpack::network::BaseNetwork< _bus, _branch >::getXCBranchBuffer | ( | int | idx | ) |
Return a pointer to exchange buffer for bus
idx | local index of bus |
void* gridpack::network::BaseNetwork< _bus, _branch >::getXCBusBuffer | ( | int | idx | ) |
Return a pointer to exchange buffer for bus
idx | local index of bus |
void gridpack::network::BaseNetwork< _bus, _branch >::initBranchUpdate | ( | void | ) |
This function must be called before calling the update branch routine. It initializes data structures for the branch update
References gridpack::parallel::Distributed::communicator(), gridpack::network::BaseNetwork< _bus, _branch >::getActiveBranch(), gridpack::network::BaseNetwork< _bus, _branch >::getGlobalBranchIndex(), and gridpack::network::BaseNetwork< _bus, _branch >::numBranches().
void gridpack::network::BaseNetwork< _bus, _branch >::initBusUpdate | ( | void | ) |
This function must be called before calling the update bus routine. It initializes data structures for the bus update
References gridpack::parallel::Distributed::communicator(), gridpack::network::BaseNetwork< _bus, _branch >::getActiveBus(), gridpack::network::BaseNetwork< _bus, _branch >::getGlobalBusIndex(), and gridpack::network::BaseNetwork< _bus, _branch >::numBuses().
int gridpack::network::BaseNetwork< _bus, _branch >::numBranches | ( | void | ) |
Number of local branches (both active and inactive) on processor
int gridpack::network::BaseNetwork< _bus, _branch >::numBuses | ( | void | ) |
Number of local buses (both active and inactive) on processor
void gridpack::network::BaseNetwork< _bus, _branch >::partition | ( | void | ) |
Partition the network over the available processes
References gridpack::network::BaseNetwork< _bus, _branch >::addBranchNeighbor(), gridpack::network::BaseNetwork< _bus, _branch >::clearBranchNeighbors(), gridpack::parallel::Distributed::communicator(), gridpack::utility::CoarseTimer::createCategory(), gridpack::parallel::DistributedInterface::processor_rank(), gridpack::network::BaseNetwork< _bus, _branch >::setGlobalBusIndex1(), gridpack::network::BaseNetwork< _bus, _branch >::setGlobalBusIndex2(), gridpack::network::BaseNetwork< _bus, _branch >::setMap(), gridpack::utility::CoarseTimer::start(), and gridpack::utility::CoarseTimer::stop().
void gridpack::network::BaseNetwork< _bus, _branch >::resetGlobalIndices | ( | bool | flag | ) |
Reset global indices on buses and branches
flag | if true reset indices on all buses and branches. If false, assume that global indices have already been set on local buses and local branches and only assign indices to ghost buses and branches |
References gridpack::hash_map::GlobalIndexHashMap::addPairs(), gridpack::parallel::Distributed::communicator(), gridpack::network::BaseNetwork< _bus, _branch >::getActiveBranch(), gridpack::network::BaseNetwork< _bus, _branch >::getActiveBus(), gridpack::network::BaseNetwork< _bus, _branch >::getGlobalBranchIndex(), gridpack::network::BaseNetwork< _bus, _branch >::getGlobalBusIndex(), gridpack::network::BaseNetwork< _bus, _branch >::getOriginalBranchEndpoints(), gridpack::network::BaseNetwork< _bus, _branch >::getOriginalBusIndex(), gridpack::hash_map::GlobalIndexHashMap::getValues(), gridpack::network::BaseNetwork< _bus, _branch >::setGlobalBranchIndex(), and gridpack::network::BaseNetwork< _bus, _branch >::setGlobalBusIndex().
bool gridpack::network::BaseNetwork< _bus, _branch >::setActiveBranch | ( | int | idx, | |
bool | flag | |||
) |
Set the active flag of the branch
idx | local index of branch | |
flag | flag for setting bus as active or inactive |
bool gridpack::network::BaseNetwork< _bus, _branch >::setActiveBus | ( | int | idx, | |
bool | flag | |||
) |
Set the active flag of the bus
idx | local index of bus | |
flag | flag for setting bus as active or inactive |
bool gridpack::network::BaseNetwork< _bus, _branch >::setGlobalBranchIndex | ( | int | idx, | |
int | g_idx | |||
) |
Set the global index of the branch
idx | local index of branch | |
g_idx | global index to be assigned to branch |
bool gridpack::network::BaseNetwork< _bus, _branch >::setGlobalBusIndex | ( | int | idx, | |
int | g_idx | |||
) |
Set the global index of the bus
idx | local index of bus | |
g_idx | global index to be assigned to bus |
bool gridpack::network::BaseNetwork< _bus, _branch >::setGlobalBusIndex1 | ( | int | idx, | |
int | b_idx | |||
) |
Set the global index of the bus at the "from" end of branch
idx | local index of branch | |
b_idx | global index of "from" bus for this branch |
bool gridpack::network::BaseNetwork< _bus, _branch >::setGlobalBusIndex2 | ( | int | idx, | |
int | b_idx | |||
) |
Set the global index of the bus at the "to" end of branch
idx | local index of branch | |
b_idx | global index of "to" bus for this branch |
bool gridpack::network::BaseNetwork< _bus, _branch >::setLocalBusIndex1 | ( | int | idx, | |
int | b_idx | |||
) |
Set the local index of the bus at the "from" end of branch
idx | local index of branch | |
b_idx | local index of "from" bus for this branch |
bool gridpack::network::BaseNetwork< _bus, _branch >::setLocalBusIndex2 | ( | int | idx, | |
int | b_idx | |||
) |
Set the local index of the bus at the "to" end of branch
idx | local index of branch | |
b_idx | local index of "to" bus for this branch |
void gridpack::network::BaseNetwork< _bus, _branch >::setMap | ( | void | ) |
Set up multimap data structures on each processor
References gridpack::network::BaseNetwork< _bus, _branch >::getOriginalBranchEndpoints(), gridpack::network::BaseNetwork< _bus, _branch >::getOriginalBusIndex(), gridpack::network::BaseNetwork< _bus, _branch >::numBranches(), and gridpack::network::BaseNetwork< _bus, _branch >::numBuses().
bool gridpack::network::BaseNetwork< _bus, _branch >::setOriginalBusIndex | ( | int | idx, | |
int | o_idx | |||
) |
Set the original index of the bus (from configuration file)
idx | local index of bus | |
o_idx | original index assigned to bus |
bool gridpack::network::BaseNetwork< _bus, _branch >::setOriginalBusIndex1 | ( | int | idx, | |
int | b_idx | |||
) |
Set the original index of the bus at the "from" end of branch
idx | local index of branch | |
b_idx | original index of "from" bus for this branch |
bool gridpack::network::BaseNetwork< _bus, _branch >::setOriginalBusIndex2 | ( | int | idx, | |
int | b_idx | |||
) |
Set the original index of the bus at the "to" end of branch
idx | local index of branch | |
b_idx | original index of "to" bus for this branch |
void gridpack::network::BaseNetwork< _bus, _branch >::setReferenceBus | ( | int | idx | ) |
Designate a bus as a reference bus.
idx | local index of bus |
void gridpack::network::BaseNetwork< _bus, _branch >::setXCBranchBuffer | ( | int | idx, | |
void * | ptr | |||
) |
Store location of externally allocated buffer within a network
idx | local index of branch associated with buffer | |
ptr | location of buffer |
void gridpack::network::BaseNetwork< _bus, _branch >::setXCBusBuffer | ( | int | idx, | |
void * | ptr | |||
) |
Store location of externally allocated buffer within a network
idx | local index of bus associated with buffer | |
ptr | location of buffer |
int gridpack::network::BaseNetwork< _bus, _branch >::totalBranches | ( | void | ) |
Return the total number of branches in the entire network
References gridpack::parallel::Distributed::communicator().
int gridpack::network::BaseNetwork< _bus, _branch >::totalBuses | ( | void | ) |
Return the total number of buses in the entire network
References gridpack::parallel::Distributed::communicator().
void gridpack::network::BaseNetwork< _bus, _branch >::updateBranches | ( | void | ) |
Update the branch ghost values. This is a collective operation across all processors.
References gridpack::parallel::Distributed::communicator(), gridpack::network::BaseNetwork< _bus, _branch >::getActiveBranch(), and gridpack::network::BaseNetwork< _bus, _branch >::numBranches().
void gridpack::network::BaseNetwork< _bus, _branch >::updateBuses | ( | void | ) |
Update the bus ghost values. This is a collective operation across all processors.
References gridpack::parallel::Distributed::communicator(), gridpack::network::BaseNetwork< _bus, _branch >::getActiveBus(), and gridpack::network::BaseNetwork< _bus, _branch >::numBuses().
void gridpack::network::BaseNetwork< _bus, _branch >::writeGraph | ( | const std::string & | outname | ) |
Print out network topology to a file using Matlab format
outname | name of file containing network topology |
References gridpack::parallel::Distributed::communicator(), gridpack::parallel::DistributedInterface::processor_rank(), and gridpack::parallel::DistributedInterface::processor_size().